#include <stdio.h>
struct people{
    char name[10];
    double jb,fd,zc,sf;
};
int main()
{
	int n;
	scanf("%d",&n);
	struct people p[n];
	for(int i=0;i<n;i++){
		
		scanf("%s %lf %lf %lf",&p[i].name,&p[i].jb,&p[i].fd,&p[i].zc);
		p[i].sf=p[i].jb+p[i].fd-p[i].zc;
	
	}
	for(int i=0;i<n;i++){
		printf("%s %.2lf",p[i].name,p[i].sf);
	}
	
	
	
	
	return 0;
}
